<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <!-- 主表单区域 -->
      <a-form-model ref="form" :model="model.purchaseProject" :rules="validatorRules" slot="detail">
         <a-card title="单位信息">
          <a-col :span="8">
            <a-form-model-item label="采购人名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaserName">
              <a-input v-model="model.purchaseProject.purchaserName" placeholder="请输入采购人名称"  ></a-input>
            </a-form-model-item>
          </a-col> 
          <a-col :span="8">
            <a-form-model-item label="采购项目联系人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaserconnector">
              <a-input v-model="model.purchaseProject.purchaserconnector" placeholder="请输入采购项目联系人"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="采购项目联系人电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchasercontactinformation">
              <a-input v-model="model.purchaseProject.purchasercontactinformation" placeholder="请输入采购项目联系人电话"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="采购项目联系人手机" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaserconnectormobile">
              <a-input v-model="model.purchaseProject.purchaserconnectormobile" placeholder="请输入采购项目联系人手机"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="采购项目联系人职务" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaserconnectorzhiwu">
              <a-input v-model="model.purchaseProject.purchaserconnectorzhiwu" placeholder="请输入采购项目联系人职务"  ></a-input>
            </a-form-model-item>
          </a-col> 
        </a-card>
        <a-card title="项目信息" style="margin-top: 15px" >
            <a-col :span="8">
            <a-form-model-item label="项目编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseProjectCode">
              <a-input v-model="model.purchaseProject.purchaseProjectCode" placeholder="请输入项目编号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="项目名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseProjectName">
              <a-input v-model="model.purchaseProject.purchaseProjectName" placeholder="请输入项目名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="项目类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tenderProjectType">
              <j-dict-select-tag type="list" v-model="model.purchaseProject.tenderProjectType" dictCode="cg_project_type" placeholder="请选择项目类型" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="项目预算" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="programBudget">
              <a-input-number v-model="model.purchaseProject.programBudget" placeholder="请输入项目预算" style="width: 100%" />
            </a-form-model-item>
          </a-col> 
          <a-col :span="8">
            <a-form-model-item label="是否ppp项目" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isProject">
              <j-dict-select-tag type="radio" v-model="model.purchaseProject.isProject" dictCode="yn" placeholder="请选择是否ppp项目" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="采购方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaserMode">
              <j-dict-select-tag type="list" v-model="model.purchaseProject.purchaserMode" dictCode="cg_type" placeholder="请选择采购方式" />
            </a-form-model-item>
          </a-col>
           <a-col :span="8">
            <a-form-model-item label="项目所在行政区划" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="regioncode">
              <j-dict-select-tag type="list" v-model="model.purchaseProject.regioncode" dictCode="sys_xz_area" placeholder="请选择项目所在行政区划" />
            </a-form-model-item>
          </a-col> 
          <a-col :span="8">
            <a-form-model-item label="项目行业分类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="industriestype">
               <j-category-select v-model="model.purchaseProject.industriestype" pcode="A04" />
            </a-form-model-item>
          </a-col>
           <a-col :span="24">
            <a-form-model-item label="项目地址"  :labelCol="{ lg: { span: 3 }, sm: { span: 4 } }"
                :wrapperCol="{ lg: { span: 21 }, sm: { span: 20 } }" prop="projectaddress">
              <a-textarea v-model="model.purchaseProject.projectaddress" rows="4" placeholder="请输入项目地址" />
            </a-form-model-item>
          </a-col>
        </a-card>
        <a-card title="采购情况"  style="margin-top: 15px" >
          <a-col :span="24">
            <a-form-model-item label="采购内容"   :labelCol="{ lg: { span: 3 }, sm: { span: 4 } }"
                :wrapperCol="{ lg: { span: 21 }, sm: { span: 20 } }" prop="purchaserContent">
              <a-textarea v-model="model.purchaseProject.purchaserContent" rows="4" placeholder="请输入采购内容" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="采购组织形式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaserOrganizeForm">
              <j-dict-select-tag type="list" v-model="model.purchaseProject.purchaserOrganizeForm" dictCode="cg_org_type" placeholder="请选择采购组织形式" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="采购代理机构名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaserAgencyName">
              <a-input v-model="model.purchaseProject.purchaserAgencyName" placeholder="请输入采购代理机构名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="采购代理机构代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaserAgencyCode">
              <a-input v-model="model.purchaseProject.purchaserAgencyCode" placeholder="请输入采购代理机构代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="采购代理机构角色" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaserAgencyRole">
              <a-input v-model="model.purchaseProject.purchaserAgencyRole" placeholder="请输入采购代理机构角色"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="采购代理机构联系人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaserAgencyConnector">
              <a-input v-model="model.purchaseProject.purchaserAgencyConnector" placeholder="请输入采购代理机构联系人"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="采购代理机构联系电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaserAgencyInformation">
              <a-input v-model="model.purchaseProject.purchaserAgencyInformation" placeholder="请输入采购代理机构联系电话"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="采购项目子包编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseSectionCode">
              <a-input v-model="model.purchaseProject.purchaseSectionCode" placeholder="请输入采购项目子包编号"  ></a-input>
            </a-form-model-item>
          </a-col> 
          <a-col :span="8">
            <a-form-model-item label="采购项目子包名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseSectionName">
              <a-input v-model="model.purchaseProject.purchaseSectionName" placeholder="请输入采购项目子包名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="监督部门名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="superviseDeptName">
              <a-input v-model="model.purchaseProject.superviseDeptName" placeholder="请输入监督部门名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="监督部门代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="superviseDeptCode">
              <a-input v-model="model.purchaseProject.superviseDeptCode" placeholder="请输入监督部门代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="审核部门名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="approveDeptName">
              <a-input v-model="model.purchaseProject.approveDeptName" placeholder="请输入审核部门名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="审核部门代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="approveDeptCode">
              <a-input v-model="model.purchaseProject.approveDeptCode" placeholder="请输入审核部门代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="统一交易标识码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="unifiedDealCode">
              <a-input v-model="model.purchaseProject.unifiedDealCode" placeholder="请输入统一交易标识码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="交易系统标识码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="platformCode">
              <a-input v-model="model.purchaseProject.platformCode" placeholder="请输入交易系统标识码"  ></a-input>
            </a-form-model-item>
          </a-col>
         
          <a-col :span="8">
            <a-form-model-item label="项目批准备案文号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="projectapprovalrecordno">
              <a-input v-model="model.purchaseProject.projectapprovalrecordno" placeholder="请输入项目批准备案文号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="资金来源" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fundsource">
              <j-dict-select-tag type="list" v-model="model.purchaseProject.fundsource" dictCode="cg_capital_source" placeholder="请选择资金来源" />
            </a-form-model-item>
          </a-col>
          
          <a-col :span="8">
            <a-form-model-item label="财政委托编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="financeentrustcode">
              <a-input v-model="model.purchaseProject.financeentrustcode" placeholder="请输入财政委托编号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="项目类别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zhaobiaolbXlCode">
              <a-input v-model="model.purchaseProject.zhaobiaolbXlCode" placeholder="请输入项目类别"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="招标模式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xiangmumoshi">
              <a-input v-model="model.purchaseProject.xiangmumoshi" placeholder="请输入招标模式"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="是否基础设施和公用事业特许经营权" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isjcandsy">
              <j-dict-select-tag type="radio" v-model="model.purchaseProject.isjcandsy" dictCode="yn" placeholder="请选择是否基础设施和公用事业特许经营权" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="是否包含机电国际招投标" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isgjzb">
              <j-dict-select-tag type="radio" v-model="model.purchaseProject.isgjzb" dictCode="yn" placeholder="请选择是否包含机电国际招投标" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="监管办专管员" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="supervisionname">
              <a-input v-model="model.purchaseProject.supervisionname" placeholder="请输入监管办专管员"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="监管办专管员联系电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="supervisionnametel">
              <a-input v-model="model.purchaseProject.supervisionnametel" placeholder="请输入监管办专管员联系电话"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="归口业务处室" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="econormicname">
              <a-input v-model="model.purchaseProject.econormicname" placeholder="请输入归口业务处室"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="资格审查方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zigeshenchatype">
              <a-input v-model="model.purchaseProject.zigeshenchatype" placeholder="请输入资格审查方式"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="自行采购核准文号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zixingwenhao">
              <a-input v-model="model.purchaseProject.zixingwenhao" placeholder="请输入自行采购核准文号"  ></a-input>
            </a-form-model-item>
          </a-col>
         <a-col :span="24">
            <a-form-model-item label="附件"  :labelCol="{ lg: { span: 3 }, sm: { span: 4 } }"
                :wrapperCol="{ lg: { span: 21 }, sm: { span: 20 } }" prop="attachmentCode">
              <j-upload :projectUploadFlag="true" v-model="model.attachmentCode"></j-upload>
            </a-form-model-item>
          </a-col>  
              </a-card>
              
        <a-row v-if="false">
          <a-col :span="8">
            <a-form-model-item label="采购项目编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="projectCode">
              <a-input v-model="model.projectCode" placeholder="请输入项目编号"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="项目名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="projectName">
              <a-input v-model="model.projectName" placeholder="请输入项目名称"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="项目所在行政区域" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="regionCode">
              <j-dict-select-tag
                type="list"
                v-model="model.regionCode"
                dictCode="sys_xz_area"
                placeholder="请选择项目所在行政区域"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item
              label="投资项目统一代码"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              prop="investProjectCode"
            >
              <a-input v-model="model.investProjectCode" placeholder="请输入投资项目统一代码"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="项目地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="address">
              <a-input v-model="model.address" placeholder="请输入项目地址"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="项目法人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="legalPerson">
              <a-input v-model="model.legalPerson" placeholder="请输入项目法人"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="项目行业分类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="industriesType">
              <j-category-select v-model="model.industriesType" pcode="A04" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="资金来源" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fundSource">
              <a-input v-model="model.fundSource" placeholder="请输入资金来源"></a-input>
            </a-form-model-item>
          </a-col>
          <!--
          <a-col :span="8">
            <a-form-model-item label="出资比例" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contributionScale">
              <a-input v-model="model.contributionScale" placeholder="请输入出资比例"></a-input>
            </a-form-model-item>
          </a-col>
          -->
          <a-col :span="8">
            <a-form-model-item label="项目规模" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="projectScale">
              <a-input v-model="model.projectScale" placeholder="请输入项目规模"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="联系人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactor">
              <a-input v-model="model.contactor" placeholder="请输入联系人"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="联系方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactInformation">
              <a-input v-model="model.contactInformation" placeholder="请输入联系方式"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="是否立项" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="islixiang">
              <j-dict-select-tag type="radio" v-model="model.islixiang" dictCode="yn" placeholder="请选择是否立项" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="不立项原因" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="notlixiang">
              <a-input v-model="model.notlixiang" placeholder="请输入不立项原因"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item
              label="监督部门名称"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              prop="superviseDeptName"
            >
              <a-input v-model="model.superviseDeptName" placeholder="请输入监督部门名称"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item
              label="监督部门代码"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              prop="superviseDeptCode"
            >
              <a-input v-model="model.superviseDeptCode" placeholder="请输入监督部门代码"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item
              label="项目审批文件名称"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              prop="approvalName"
            >
              <a-input v-model="model.approvalName" placeholder="请输入项目审批文件名称"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="项目审批文号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="approvalNumber">
              <a-input v-model="model.approvalNumber" placeholder="请输入项目审批文号"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item
              label="项目审批单位"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              prop="approvalAuthority"
            >
              <a-input v-model="model.approvalAuthority" placeholder="请输入项目审批单位"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="附件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachmentCode">
              <j-upload :projectUploadFlag="true" v-model="model.attachmentCode"></j-upload>
            </a-form-model-item>
          </a-col>
          <!--
          <a-col :span="8">
            <a-form-model-item label="交易系统标识码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="platformCode">
              <a-input v-model="model.platformCode" placeholder="请输入交易系统标识码"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item
              label="国有资金（万元）"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              prop="stateOwnedFund"
            >
              <a-input-number v-model="model.stateOwnedFund" placeholder="请输入国有资金（万元）" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item
              label="国有资金比例%"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              prop="stateOwnedFundRatio"
            >
              <a-input-number :min="0"
                v-model="model.stateOwnedFundRatio"
                placeholder="请输入国有资金比例%"
                style="width: 100%"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item
              label="私有资金（万元）"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              prop="privateFund"
            >
              <a-input-number v-model="model.privateFund" placeholder="请输入私有资金（万元）" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item
              label="私有资金比例%"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              prop="privateFundRatio"
            >
              <a-input-number v-model="model.privateFundRatio" placeholder="请输入私有资金比例%"  :min="0" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item
              label="外国政府及组织投资（万元）"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              prop="foreignFund"
            >
              <a-input-number
                v-model="model.foreignFund"
                placeholder="请输入外国政府及组织投资（万元）"
                style="width: 100%"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item
              label="外国政府及组织投资比例"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              prop="foreignFundRatio"
            >
              <a-input-number
                v-model="model.foreignFundRatio"
                placeholder="请输入外国政府及组织投资比例"
                style="width: 100%"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item
              label="境外私人投资（万元）"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              prop="foreignPrivateFund"
            >
              <a-input-number
                v-model="model.foreignPrivateFund"
                placeholder="请输入境外私人投资（万元）"
                style="width: 100%"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item
              label="境外私人投资比例%"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              prop="foreignPrivateFundRatio"
            >
              <a-input-number :min="0"
                v-model="model.foreignPrivateFundRatio"
                placeholder="请输入境外私人投资比例%"
                style="width: 100%"
              />
            </a-form-model-item>
          </a-col>
          -->
        </a-row>
      </a-form-model>
    </j-form-container>
    <a-card title="标段信息" style="margin: 15px 0px;" :body-style="{ padding: '2px' }">
      <section-list ref="sectionListRef" :projectId="model.id" :disabled="formDisabled" @ok="sectionListOk" />
    </a-card>
    <ex-operation-record ref="exOperationRecord" :module="'exProject'" :entryId="model.id"></ex-operation-record>
  </a-spin>
</template>

<script>
import { httpAction, getAction } from '@/api/manage'
import { FormTypes, getRefPromise, VALIDATE_NO_PASSED } from '@/utils/JEditableTableUtil'
import { validateDuplicateValue } from '@/utils/util'
import SectionList from '@/views/exProject/section/SectionList'
import ExOperationRecord from '@/views/exOperationRecord/Index'
export default {
  name: 'ExProjectCgForm',
  components: {
    SectionList,
    ExOperationRecord,
  },
  data() {
    return {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 9 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 15 },
      },
      model: {
        purchaseProject:{}
      },
      // 新增时子表默认添加几行空数据
      addDefaultRowNum: 1,
      validatorRules: {
        projectId: [{ required: true, message: '请输入项目标识码 (guid)!' }],
        projectCode: [{ required: true, message: '请输入项目编号!' }],
        projectName: [{ required: true, message: '请输入项目名称!' }],
        regionCode: [{ required: true, message: '请输入项目所在行政区域代码!' }],

         purchaseProjectCode: [
              { required: true, message: '请输入采购项目编号!'},
           ],
           purchaseProjectName: [
              { required: true, message: '请输入采购项目名称!'},
           ],
           tenderProjectType: [
              { required: true, message: '请输入采购项目类型!'},
           ],
           purchaserName: [
              { required: true, message: '请输入采购人名称!'},
           ],
           purchaserCode: [
              { required: true, message: '请输入采购人代码!'},
           ],
           purchaserRole: [
              { required: true, message: '请输入采购人角色!'},
           ],
           programBudget: [
              { required: false},
              { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
           ],
           purchaserMode: [
              { required: true, message: '请输入采购方式!'},
           ],
           purchaserOrganizeForm: [
              { required: true, message: '请输入采购组织形式!'},
           ],
           purchaserAgencyName: [
              { required: true, message: '请输入采购代理机构名称!'},
           ],
           purchaserAgencyCode: [
              { required: true, message: '请输入采购代理机构代码!'},
           ],
           purchaserAgencyRole: [
              { required: true, message: '请输入采购代理机构角色!'},
           ],
           purchaseSectionCode: [
              { required: true, message: '请输入采购项目子包编号!'},
           ],
           purchaseSectionName: [
              { required: true, message: '请输入采购项目子包名称!'},
           ],
           superviseDeptName: [
              { required: true, message: '请输入监督部门名称!'},
           ],
           approveDeptName: [
              { required: true, message: '请输入审核部门名称!'},
           ],
           unifiedDealCode: [
              { required: true, message: '请输入统一交易标识码!'},
           ],
           platformCode: [
              { required: true, message: '请输入交易系统标识码!'},
           ],
           regioncode: [
              { required: true, message: '请输入项目所在行政区划代码!'},
           ],
           projectaddress: [
              { required: true, message: '请输入项目地址!'},
           ],
           industriestype: [
              { required: true, message: '请输入项目行业分类!'},
           ],
           fundsource: [
              { required: true, message: '请输入资金来源!'},
           ],
           purchaserconnector: [
              { required: true, message: '请输入采购项目联系人!'},
           ],
           purchasercontactinformation: [
              { required: true, message: '请输入采购项目联系人电话!'},
           ],
           purchaserconnectormobile: [
              { required: true, message: '请输入采购项目联系人手机!'},
           ],
           purchaserconnectorzhiwu: [
              { required: true, message: '请输入采购项目联系人职务!'},
           ],
           isjcandsy: [
              { required: true, message: '请输入是否基础设施和公用事业特许经营权!'},
           ],
           isgjzb: [
              { required: true, message: '请输入是否包含机电国际招投标!'},
           ],
           zigeshenchatype: [
              { required: true, message: '请输入资格审查方式!'},
           ],
        // investProjectCode: [{ required: true, message: '请输入投资项目统一代码!' }],
        // address: [{ required: true, message: '请输入项目地址!' }],
        // legalPerson: [{ required: true, message: '请输入项目法人!' }],
        // industriesType: [{ required: true, message: '请输入项目行业分类!' }],
        // fundSource: [{ required: true, message: '请输入资金来源!' }],
        // projectScale: [{ required: true, message: '请输入项目规模!' }],
        // contactor: [{ required: true, message: '请输入联系人!' }],
        // contactInformation: [{ required: true, message: '请输入联系方式!' }],
        // islixiang: [{ required: true, message: '请输入是否立项!' }],
        // superviseDeptName: [{ required: true, message: '请输入监督部门名称!' }],
        // superviseDeptCode: [{ required: true, message: '请输入监督部门代码!' }],
        // platformCode: [{ required: true, message: '请输入交易系统标识码!' }],
        // stateOwnedFund: [{ required: true, message: '请输入国有资金（万元）!' }],
        // stateOwnedFundRatio: [{ required: true, message: '请输入国有资金比例!' }],
        // privateFund: [{ required: true, message: '请输入私有资金（万元）!' }],
        // privateFundRatio: [{ required: true, message: '请输入私有资金比例!' }],
        // foreignFund: [{ required: true, message: '请输入外国政府及组织投资（万元）!' }],
        // foreignFundRatio: [{ required: true, message: '请输入外国政府及组织投资比例!' }],
        // foreignPrivateFund: [{ required: true, message: '请输入境外私人投资（万元）!' }],
        // foreignPrivateFundRatio: [{ required: true, message: '请输入境外私人投资比例!' }],
      },
      refKeys: [],
      tableKeys: [],
      activeKey: '',
      // 招标项目
      exTenderProjectTable: {
        loading: false,
        dataSource: [],
        columns: [],
      },
      confirmLoading:false,
      url: {
        add: '/exProject/exProject/add',
        edit: '/exProject/exProject/edit',
        queryById: '/exProject/exProject/queryById', 
      },
    }
  },
  props: {
    //表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false,
    },
  },
  computed: {
    formDisabled() {
      return this.disabled
    },
  },
  created() {},
  methods: {
    edit(record) {
      var that  = this
      getAction(this.url.queryById, { id: record.id }).then((res) => {
        if (res.success) {
          var result = res.result 
          that.visible = true
          that.$refs.form.resetFields()
          that.model = Object.assign({}, result) 
        }
      }) 
    },
     editAfter() {
     },
    getAllTable() {
      let values = this.tableKeys.map((key) => getRefPromise(this, key))
      return Promise.all(values)
    },  
    /** 整理成formData */
    classifyIntoFormData(allValues) {
      let main = Object.assign(this.model, allValues.formValue)
      return {
        ...main, // 展开
        exTenderProjectList: this.$refs.exTenderProjectForm.getFormData(),
      }
    },
    validateError(msg) {
      this.$message.error(msg)
    },
    sectionListOk() {
      this.model.exSectionList = this.$refs.sectionListRef.dataSource
    },
    handleOk() {
      const that = this
      this.model.exSectionList = this.$refs.sectionListRef.dataSource
      if(this.model.exSectionList.length == 0){
          that.$message.warning("标段信息不能为空")
          return;
      }
      // 触发表单验证
      this.$refs.form.validate((valid) => {
        //that.validateSubForm(0)
        // debugger
        // var valid2 = that.$refs.exTenderProjectForm.validate2()
        if (valid) {
         that.save()
        }
      })
    },
    save() {
      var that = this
      that.confirmLoading = true
      let httpurl = ''
      let method = ''
      if (!this.model.id) {
        httpurl += this.url.add
        method = 'post'
      } else {
        httpurl += this.url.edit
        method = 'put'
      }
      httpAction(httpurl, this.model, method)
        .then((res) => {
          if (res.success) {
            that.$message.success(res.message)
            that.$emit('ok')
          } else {
            that.$message.warning(res.message)
          }
        })
        .finally(() => {
          that.confirmLoading = false
        })
    },
  },
}
</script>

<style scoped></style>
